package com.glsc.ngateway.common.base.domain.mysql.opmanagemain.deposit;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.glsc.ngateway.common.api.common.enums.DictConstant;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author liwei
 * 保证金管理-存管银行
 */
@Data
@Entity
@Table(name = "t_deposit_bank_config")
@org.hibernate.annotations.Table(appliesTo = "t_deposit_bank_config", comment = "存管银行配置")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Where(clause = "deleted = 'N'")
@SQLDelete(sql = "update t_deposit_bank_config set deleted = 'Y' where id=?")
@SQLDeleteAll(sql = "update t_deposit_bank_config set deleted = 'Y' where id=?")
public class DepositoryBank implements Serializable {
    private static final long serialVersionUID = 1680934714124742795L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", columnDefinition = "int(20) comment '存管银行id'")
    private Integer id;

    @ApiModelProperty(value = "银行名称")
    @Column(name = "bank_name", columnDefinition = "varchar(255) COMMENT '银行名称'")
    private String bankName;

    @ApiModelProperty(value = "存款账户类型")
    @Column(name = "account_type", columnDefinition = "varchar(60) COMMENT '存款账户类型，数据字典：t_deposit_bank_account_type'")
    private String accountType;

    @ApiModelProperty(value = "开户行")
    @Column(name = "open_account_bank", columnDefinition = "varchar(200) COMMENT '开户行'")
    private String openAccountBank;

    @ApiModelProperty(value = "存管账号")
    @Column(name = "account", columnDefinition = "varchar(200) COMMENT '存管账号'")
    private String account;

    @ApiModelProperty(value = "银行账户")
    @Column(name = "account_name", columnDefinition = "varchar(200) COMMENT '银行账户'")
    private String accountName;

    @ApiModelProperty(value = "利率")
    @Column(name = "interest_rate", columnDefinition = "decimal(16,4) COMMENT '利率'")
    private BigDecimal interestRate;

    @ApiModelProperty(value = "存管费率")
    @Column(name = "fee_rate", columnDefinition = "decimal(16,4) COMMENT '存管费率'")
    private BigDecimal feeRate;

    @ApiModelProperty(value = "最低存放类型")
    @Column(name = "deposit_floor_type", columnDefinition = "varchar(255) COMMENT '最低存放类 型数据字典：t_depository_floor_type '")
    private String depositFloorType;

    @ApiModelProperty(value = "最低存放")
    @Column(name = "deposit_floor", columnDefinition = "decimal(16,4) COMMENT '最低存放'")
    private BigDecimal depositFloor;

    @ApiModelProperty(value = "备注")
    @Column(name = "memo", columnDefinition = "varchar(255) COMMENT '备注'")
    private String memo;

    @Column(name = "create_id", columnDefinition = "int DEFAULT NULL COMMENT '创建人id'")
    @ApiModelProperty(value = "创建人id")
    private Long createId;

    @ApiModelProperty(value = "创建人名称")
    @Column(name = "create_name", columnDefinition = "varchar(100) COMMENT '创建人名称'")
    private String createName;

    @ApiModelProperty(value = "创建时间 yyyy-MM-dd HH:mm:ss")
    @Column(name = "create_time", columnDefinition = "datetime comment '创建时间'", updatable = false)
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createTime;

    @ApiModelProperty(value = "是否删除，字典 YesNo:（N=未删除(默认) Y=已删除)")
    @Column(name = "deleted", columnDefinition = "varchar(20) default 'N' COMMENT '是否删除，字典 yesno （N=否(默认) Y=是)'")
    private String deleted = DictConstant.NO;

}
